#include "mainwindow.h"
#include "QMenuBar"
#include "QToolBar"
#include "QPushButton"
#include "QStatusBar"
#include "QLabel"
#include "QDockWidget"
#include "QTextEdit"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    resize(600, 400);


    QMenuBar* bar = new QMenuBar(this);

    QMenu *file = bar->addMenu("文件");
    QAction *newAction = file->addAction("新建");
    QAction *openAction = file->addAction("打开");

    QMenu *edit = bar->addMenu("编辑");

    setMenuBar(bar);
    bar->setNativeMenuBar(false);

    QToolBar *toolBar = new QToolBar(this);
    addToolBar(Qt::LeftToolBarArea, toolBar);
    // 只允许左右停靠
    toolBar->setAllowedAreas(Qt::LeftToolBarArea | Qt:: RightToolBarArea);

    toolBar->setFloatable(false);
    toolBar->setMovable(true);

    toolBar->addAction(newAction);
    toolBar->addAction(openAction);

    QPushButton *pButton = new QPushButton("aa", this);
    toolBar->addWidget(pButton);
    
    // 状态栏
    QStatusBar *pBar = new QStatusBar(this);
    setStatusBar(pBar);

    QLabel *pLabel = new QLabel("提示信息", this);
    pBar->addWidget(pLabel);

    // 铆接部件（浮动窗口）
    QDockWidget *pWidget = new QDockWidget(this);
    addDockWidget(Qt::BottomDockWidgetArea, pWidget);
    pWidget->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);

//    QTextEdit *pEdit = new QTextEdit(this);
//    setCentralWidget(edit);

}

MainWindow::~MainWindow()
{
}

